package com.boot.test;

import org.mindrot.jbcrypt.BCrypt;

/**
 * @Auther: zhengshunzhi
 * @Date: 2018/8/31 18:00
 * @Description:
 */
public class BCryptDemo {
    public static void main(String[] args) {
        String password = "zhengshunzhi";
        String hashed = BCrypt.hashpw(password, BCrypt.gensalt());
        //通过调用BCrypt类的静态方法hashpw对password进行加密。第二个参数就是我们平时所说的加盐。
        String hashed2 = BCrypt.hashpw(password, BCrypt.gensalt(123456));
        System.out.println(hashed + "\t" + hashed2);
        System.out.println(BCrypt.checkpw(password, hashed2));
    }
}
